package cn.tedu.spring.resource;

import cn.tedu.spring.config.SpringConfig;
import cn.tedu.spring.resource.controller.ReController;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class TestResource {
    //xml方式组件扫描
    @Test
    public void testResource() {
        ApplicationContext context = new ClassPathXmlApplicationContext("bean.xml");
        ReController reController = context.getBean(ReController.class);
        reController.con();

    }

    //使用配置类开启组件扫描
    @Test
    public void configTest() {
        ApplicationContext context = new AnnotationConfigApplicationContext(SpringConfig.class);
        ReController reController = context.getBean(ReController.class);
        reController.con();
    }
}
